package library.base.mvp;

import android.os.Bundle;

import org.greenrobot.eventbus.Subscribe;

import library.base.mvp.presenter.BasePresenter;
import library.base.mvp.presenter.event.BaseEvent;

/**
 * @author Created by qiang.hou on 2018/4/6.
 * @version 1.0
 */
public interface IContract {

    /**
     * @author Created by qiang.hou on 2018/3/2.
     * @version 1.0
     */
    interface IView {
        @Subscribe
        <E extends BaseEvent> void onEventMessageReceive(E event);
    }

    /**
     * @author Created by qiang.hou on 2018/3/2.
     * @version 1.0
     */
    interface IPresenter {
        void doInitProcess();

        void onCreate();

        void onStart();

        void onResume();

        void onPause();

        void onStop();

        void onSaveInstanceState(Bundle savedInstanceState);

        void onDestroy();
    }

    /**
     * @author Created by qiang.hou on 2018/5/7.
     * @version 1.0
     */
    interface IModule {

        <T, E extends Throwable> void notifyModel(T data, IModelObserver<T, E> observer);

        <T, E extends Throwable> void notifyError(E throwable, IModelObserver<T, E> observer);

        /**
         * @author Created by qiang.hou on 2018/5/9.
         * @version 1.0
         */
        interface IModelObserver<T, E extends Throwable> {
            void onNotify(T data);

            void onError(E e);
        }
    }

    /**
     * @author Created by qiang.hou on 2018/3/2.
     * @version 1.0
     */
    interface IPresenterManager {
        BasePresenter getPresenter(String localClassPath);

        void addPresenter(String localClassPath, BasePresenter presenter);
    }
}
